home *** CD-ROM | disk | FTP | other *** search
- Path: robertk.accessone.com!user
- From: robertk@accessone.com (robertk)
- Newsgroups: comp.lang.c
- Subject: very simple newbie question with correction
- Date: 1 Mar 1996 07:02:32 GMT
- Organization: Kingdom
- Message-ID: <robertk-0103960001470001@robertk.accessone.com>
- NNTP-Posting-Host: robertk.accessone.com
-
- sorry... reposting this with "s\n" in the 2nd example instead of my
- original "%s/n" .... how come.....when i do this ....
-
-
- #include <stdio.h>
- main()
- {
- char s[10];
- scanf("%s",s);
- printf("%s",s);
- }
-
- when i run this and input:
-
- robert <enter> --->soon as i hit the enter key i am
- thrown back to the ide-upon returning to
- the screen i see
- robert
- robert
-
- BUT...........
-
- #include <stdio.h>
- main()
- {
- char s[10];
- scanf("%s\n",s);
- printf("%s",s);
- }
-
- when i run this and input:
-
- robert <enter> --->when i hit the enter key the cursor
- drops down a line and sits ther flashing
- waiting for me to enter another character
- like x before it will throw me back to the
- ide. upon returning to the screen i see
- robert
- x
- robert
-
- i thought scanf() ignored whitespace?
-